package com.kunge2013.chatbi.vectordb.impl;

import com.kunge2013.chatbi.vectordb.VectorDbService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.ai.document.Document;
import org.springframework.ai.vectorstore.SearchRequest;
import org.springframework.ai.vectorstore.VectorStore;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Optional;

/**
 * @Author kunge2013
 * @Description 向量数据处理接口
 * @Date 2024/11/10 12:47
 * @Version 1.0
 */
@Service
@AllArgsConstructor
@Slf4j(topic = "vectorStore")
public class VectorDbServiceImpl implements VectorDbService {
    private final VectorStore vectorStore;

    @Override
    public void add(List<Document> documents) {
        vectorStore.add(documents);
    }

    @Override
    public Optional<Boolean> delete(List<String> idList) {
        return vectorStore.delete(idList);
    }

    @Override
    public List<Document> similaritySearch(SearchRequest request) {
        return vectorStore.similaritySearch(request);
    }
}
